package cn.itcast.bos.dao.base;

import java.util.List;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.annotation.Rollback;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.transaction.annotation.Transactional;

import cn.itcast.bos.domain.base.Standard;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations="classpath:applicationContext.xml")
public class JPATest {

	@Autowired
	private StandardRepository standardRepository;
	
	/**
	 * 删改操作
	 */
	
	
	@Test
	@Transactional
	@Rollback(false)
	public void test8() {
		standardRepository.updateMaxLength(1, 30);
		
	}
	
	@Test
	public void test9() {
		standardRepository.delete(2);
		
	}
	
	@Test
	@Transactional
	@Rollback(false)
	public void test10() {
		Standard standard = new Standard();
		standardRepository.save(standard);
		
	}
	
	
	@Test
	public void test1() {
		List<Standard> list = standardRepository.findByName("王五11");
		System.out.println(list);
	}
	
	@Test
	public void test2() {
		List<Standard> list = standardRepository.findAll();
		System.out.println(list);
	}
	
	@Test
	public void test3() {
		List<Standard> list = standardRepository.findByMinWeight(5);
		System.out.println(list);
	}
	
	@Test
	public void test4() {
		List<Standard> list = standardRepository.findByNameAndMaxWeight("50啊", 50);
		System.out.println(list);
	}
	
	/**
	 * 以下是自定义的测试
	 */
	
	@Test
	public void test5() {
		List<Standard> list = standardRepository.gtByMax(20);
		System.out.println(list);
	}
	
	@Test
	public void test6() {
		List<Standard> list = standardRepository.bwAB(15, 6);
		System.out.println(list);
	}
	
	@Test
	public void test7() {
		List<Standard> list = standardRepository.myAll();
		System.out.println(list);
	}
	
	
}
